<template>
    <div class="layout">
        <Layout :style="{minHeight: '100vh'}">
            <Sider>
                <Menu active-name="/"
                      theme="dark"
                      width="auto"
                      :class="menuitemClasses">
                    <template v-for="route of $router.options.routes">
                        <MenuItem v-if="!route.children"
                                  :name="route.path"
                                  :key="route.path"
                                  :to="route.path">
                            <Icon type="ios-analytics"/>
                            {{route.meta.title}}
                        </MenuItem>
                        <Submenu v-else
                                 :name="route.path"
                                 :key="route.path">
                            <template slot="title">
                                <Icon type="ios-analytics"/>
                                {{route.meta.title}}
                            </template>
                            <MenuItem v-for="child of route.children"
                                      :name="child.path"
                                      :key="child.path"
                                      :to="child.path">
                                <Icon type="ios-analytics"/>
                                {{child.meta.title}}
                            </MenuItem>
                        </Submenu>
                    </template>
                </Menu>
            </Sider>
            <Layout>
                <div class="header"/>
                <div class="container">
                    <div class="container__wrap">
                        <router-view class="container__router-view"/>
                    </div>
                </div>
            </Layout>
        </Layout>
    </div>
</template>
<script>
  export default {
    data() {
      return {
        isCollapsed: false,
      };
    },
    computed: {
      menuitemClasses: function () {
        return [
          'menu-item',
          this.isCollapsed ? 'collapsed-menu' : '',
        ];
      },
    },
  };
</script>
<style>
    .ivu-layout {
        background: white !important;
    }
</style>

<style lang="less" scoped>
    .layout-con {
        height: 100%;
        width: 100%;
    }

    .menu-item span {
        display: inline-block;
        overflow: hidden;
        width: 69px;
        text-overflow: ellipsis;
        white-space: nowrap;
        vertical-align: bottom;
        transition: width .2s ease .2s;
    }

    .menu-item i {
        transform: translateX(0px);
        transition: font-size .2s ease, transform .2s ease;
        vertical-align: middle;
        font-size: 16px;
    }

    .collapsed-menu span {
        width: 0px;
        transition: width .2s ease;
    }

    .collapsed-menu i {
        transform: translateX(5px);
        transition: font-size .2s ease .2s, transform .2s ease .2s;
        vertical-align: middle;
        font-size: 22px;
    }

    .header {
        display: block;
        width: 100%;
        margin-bottom: 5px;
        background-color: white;
        box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1);
    }

    .container {
        position: relative;
        display: flex;
        flex: 1 1 auto;
        box-sizing: border-box;
        background-color: white;

        &__wrap {
            display: flex;
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }

        &__router-view {
            position: relative;
            display: flex;
            flex: 1 1 auto;
            padding: 20px;
            box-sizing: border-box;
        }
    }
</style>
